
********************************
***Fix Message Vary Source***
********************************

clear all

********************
*Set Person Working*
*Change this to your name!!!!!
********************
*global carolina 0
*global emily 1

global emily 1
global carolina 0

*********************
*Load Files*
*********************

*Carolina's Computer*
if $carolina ==1  {
cap cd "~\Dropbox\Carolina-Emily-Project\Data\Study"
global out "..\..\Results\"
}


if $emily ==1  {
*Emily's Computer*
cap cd "~/Dropbox/SourceContent/Data/Study"
global out "../../Results/"
global draftout "../../Draft/Figures/"
} 

use 3_clean_data, replace

*********************************
***Create Variables and Format***
*********************************
	
global lasso0 hispanic age55_64 candidate16_hillary candidate16_other ///
	immlevel_decrease gun_lessstrict abortion_illegal tax_toohigh health_notgvt ///
	occ_twitter occ_buzzfeed trumpfan lebronfan taylorfan bgatesfan ///
	obamafan obama_neutral topissue_health 
	
global lasso1 black hispanic age35_44 age45_54 hsdegree ///
	candidate16_hillary immlevel_decrease immlevel_same ///
	gun_same gun_lessstrict abortion_partlegal abortion_illegal tax_toohigh ///
	health_neutral health_notgvt i.freq_nytimes ///
	daily_tv occ_tv daily_newspaper i.freq_fox week_breitbart ///
	daily_breitbart occ_buzzfeed ///
	lebron_neutral obamafan trump_neutral trumpfan west topissue_tax 
		
gen group1=treatment==5 | treatment==7 | treatment==0
gen group2=treatment==6 | treatment==8 | treatment==0
gen group3=treatment==1 | treatment==3 | treatment==0
gen group4=treatment==2 | treatment==4 | treatment==0

global message1 "Anti"
global message2 "Anti"
global message3 "Pro"
global message4 "Pro"

global source1 "Trump"
global source2 "Obama"
global source3 "Trump"
global source4 "Obama" 

gen president=treatment==1 | treatment==2 | treatment==5 | treatment==6
gen actor=treatment==3 | treatment==4 | treatment==7 | treatment==8
gen turkey= treatment==9 | treatment==10
gen priming=turkey==1 | president==1
gen message=actor==1 | president==1


*****************************
*****************************
*****************************

global color1 "blue"
global color0 "red"
global party0 "Republicans"
global party1 "Democrats"
global dir0 "anti"
global dir1 "pro"
global var0 "ln(Probability Anti-Immigrant + 1)"
global var1 "ln(Probability Pro-Immigrant + 1)"

global g0 "group3"
global g1 "group2"

global treat0 "Pro-Immigrant, Trump"
global treat1 "Anti-Immigrant, Obama"

***************************************************
*Distribution Plots - Likelihood of Being Convinced
*President vs. Actor*
***************************************************

gen res0=.
gen res1=.

foreach p in 0 1 {

reg ln1_prob_index_${dir`p'} ${lasso`p'} ///
	if (${g`p'}==1) & treat!=0 & recruit==`p', robust  

	predict res if e(sample)==1, res
	sum ln1_prob_index_${dir`p'} if e(sample)==1
	replace res=res+`r(mean)'
	gen g=0 if actor==1 & e(sample)==1
	replace g=1 if president==1 & e(sample)==1
	ksmirnov res if e(sample), by(g)
	local d`y'`p'=round(r(p)*10000)/10000
	local d`y'`p': di %6.3f `d`y'`p''
	replace res`p'=res if e(sample)==1
	drop g res
	
# delimit ;
twoway (kdensity res`p' if president==1 & ${g`p'}==1 & treat!=0, lcolor(black))
	(kdensity res`p' if president==0 & ${g`p'}==1 & treat!=0, lcolor(black) lpattern(dash_dot))
	,
	xtitle(" " "{it: ${var`p'}}" " ")
	ytitle(" ")
	graphregion(color(white)) 
	legend(order(1 "President" 2 "Actor") rows(1))
	text(4.5 0.2 "Prob(Dist)=`d`y'`p''")
	xscale(range(0.05(0.1)0.85)) xlabel(0.1(.1).8)
	yscale(range(0(2)6.5)) ylabel(0(2)6, nogrid) ytick(0(2)6)
	;
# delimit cr
graph export "$draftout/A4_Distribution_MessageFixed_VarySource_${party`p'}.eps", replace	

}


